from rest_framework.serializers import ModelSerializer
from rest_framework import serializers
from main.models import User, Room, DoorStatus


class UserModelSerializers(ModelSerializer):
    room_id = serializers.IntegerField()
    room_number = serializers.CharField(source='room.number')
    room_position = serializers.CharField(source='room.position')
    door_status = serializers.CharField(source='room.door_status.type')

    class Meta:
        model = User
        fields = ['username', 'room_id', 'room_number', 'room_position', 'door_status']


class RoomModelSerializers(ModelSerializer):
    door_status_id = serializers.IntegerField()
    door_status = serializers.CharField(source='door_status.type')

    class Meta:
        model = Room
        fields = ['room_number', 'room_position', 'door_status_id', 'door_status']


class DoorStatusSerializers(ModelSerializer):
    class Meta:
        model = DoorStatus
        fields = ['type']



